<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Purpricechange_model extends CI_Model {
	public function __construct() {
		parent::__construct ();
	}
	/*
	 * 添加进货价价格变动状态
	 */
	public function create($purpricechange) {
		$this->db->insert ( 't_purpricechange', $purpricechange );
		return $this->db->insert_id ();
	}
	/*
	 * 根据商品ID和起始日期得到价格变化信息(用于展示价格变化)
	 */
	public function get_by_product_date($productid,$startdate,$enddate){//
		$this->db->where('productid',$productid);
		$this->db->where("DATE_FORMAT(update_time,'%Y-%m-%d')>=",$startdate);
		$this->db->where("DATE_FORMAT(update_time,'%Y-%m-%d')<=",$enddate);
		$this->db->order_by("update_time", "asc");
		$query = $this->db->get('t_purpricechange');
		return $query->result_array();
	}
}